using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public interface Istate
{
    void OnEnter();
    void OnExit();
    void OnUpdate();
    //void OnCheck();
    //void FixUpDate();
}
[Serializable]
public class BlackBoard
{

}

public class FSM
{
    public Istate curState;
    public Dictionary<StateType,Istate> states;
    public BlackBoard blackBoard;

    public FSM(BlackBoard blackBoard)
    {
        this.states = new Dictionary<StateType,Istate>();
        this.blackBoard = blackBoard;
    }
    public void AddState(StateType stateType,Istate istate)
    {
        if (states.ContainsKey(stateType))
        {
            Debug.Log(stateType.ToString());
            return;
        }
        states.Add(stateType, istate);
    }
    public void SwitchState(StateType stateType)
    {
        if (!states.ContainsKey(stateType))
        {
            Debug.Log(stateType.ToString());
            return;
        }
        if (curState!=null)
        {
            curState.OnExit();
        }
        curState = states[stateType];
        curState.OnEnter();
    }

    public void OnUpdate()
    {
        curState.OnUpdate();
    }

}
public enum StateType
{
    Idle,
    Move,
    Attack,
    Die,
}